﻿// ***********************************************************************
// Assembly         : Logica
// Author           : Diego
// Created          : 03-02-2014
//
// Last Modified By : Diego
// Last Modified On : 03-02-2014
// ***********************************************************************
// <copyright file="LOG_Orden.cs" company="">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using AccesoDatos.Modulos.ClasesAccesoDatos;
using Modelado.Modulos.ClasesModelado;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/// <summary>
/// The ClasesLogica namespace.
/// </summary>
namespace Logica.Modulos.ClasesLogica
{
    /// <summary>
    /// Class LOG_Orden.
    /// </summary>
   public class LOG_Orden:Negocio
    {


        //insertar  Orden
        /// <summary>
        /// Crs the e_ orden.
        /// </summary>
        /// <param name="obj">The object.</param>
       public void CRE_Orden(MOD_Orden obj)
        {
            try
            {
                this.IniciarTransaccion();

                AD_Orden objBD = new AD_Orden();

                objBD.CRE_Orden(this.comando, obj);

                this.ConfirmarTransaccion();
            }
            catch (Exception exc)
            {
                this.DeshacerTransaccion();
                throw exc;
            }
        }
        //Elimina  Ordens
       /// <summary>
       /// Des the l_ orden.
       /// </summary>
       /// <param name="codigo">The codigo.</param>
        public void DEL_Orden(int codigo)
        {
            try
            {
                this.IniciarTransaccion();

                AD_Orden objBD = new AD_Orden();

                objBD.DEL_Orden(this.comando, codigo);

                this.ConfirmarTransaccion();
            }
            catch (Exception exc)
            {
                this.DeshacerTransaccion();
                throw exc;
            }
        }
        //Actualiza estado Ordens
        /// <summary>
        /// Ups the d_ orden.
        /// </summary>
        /// <param name="obj">The object.</param>
        public void UPD_Orden(MOD_Orden obj)
        {
            try
            {
                this.IniciarTransaccion();

                AD_Orden objBD = new AD_Orden();

                objBD.UPD_Orden(this.comando, obj);

                this.ConfirmarTransaccion();
            }
            catch (Exception exc)
            {
                this.DeshacerTransaccion();
                throw exc;
            }

        }

        /// <summary>
        /// Ups the d_ total_ orden.
        /// </summary>
        /// <param name="obj">The object.</param>
        public void UPD_Total_Orden( MOD_Orden obj)
        {
            try
            {
                this.IniciarTransaccion();

                AD_Orden objBD = new AD_Orden();

                objBD.UPD_Total_Orden(this.comando, obj);

                this.ConfirmarTransaccion();
            }
            catch (Exception exc)
            {
                this.DeshacerTransaccion();
                throw exc;
            }

        }

        /// <summary>
        /// Ses the l_ grid_ orden.
        /// </summary>
        /// <param name="codProyeto">The cod proyeto.</param>
        /// <returns>List{MOD_Orden}.</returns>
        public List<MOD_Orden> SEL_Grid_Orden(int codProyeto)
        {
            try
            {
                this.AbrirConexion();

                AD_Orden objBD = new AD_Orden();

                List<MOD_Orden> lista = objBD.SEL_Grid_Orden(this.comando, codProyeto);

                this.CerrarConexion();

                return lista;
            }
            catch (Exception exc)
            {
                this.CerrarConexion();
                throw exc;
            }
        }


        /// <summary>
        /// Ses the l_ orden by identifier.
        /// </summary>
        /// <param name="codorden">The codorden.</param>
        /// <returns>MOD_Orden.</returns>
        public MOD_Orden SEL_OrdenByID(int codorden)
        {
            try
            {
                this.AbrirConexion();

                AD_Orden objBD = new AD_Orden();

                MOD_Orden objOrden = objBD.SEL_OrdenByID(this.comando, codorden);

                this.CerrarConexion();

                return objOrden;
            }
            catch (Exception exc)
            {
                this.CerrarConexion();
                throw exc;
            }
        }

        /// <summary>
        /// Ses the l_ ultimocodorden.
        /// </summary>
        /// <returns>System.Int32.</returns>
        public int SEL_ULTIMOCODORDEN()
        {
            try
            {
                this.AbrirConexion();

                AD_Orden objBD = new AD_Orden();

                int cod_orden = objBD.SEL_ULTIMOCODORDEN(this.comando);

                this.CerrarConexion();

                return cod_orden;
            }
            catch (Exception exc)
            {
                this.CerrarConexion();
                throw exc;
            }
        }


    }
}
